home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 May / maximum-cd-2009-05.iso / DiscContents / gimp-2.6.5-i686-setup.exe / {app} / lib / gimp / 2.0 / python / gimpplugin,2.py < prev    next >
Encoding:
Python Source  |  2009-02-15  |  2.0 KB  |  65 lines

  1. #   Gimp-Python - allows the writing of Gimp plugins in Python.
  2. #   Copyright (C) 1997  James Henstridge <james@daa.com.au>
  3. #
  4. #    This program is free software; you can redistribute it and/or modify
  5. #   it under the terms of the GNU General Public License as published by
  6. #   the Free Software Foundation; either version 2 of the License, or
  7. #   (at your option) any later version.
  8. #
  9. #   This program is distributed in the hope that it will be useful,
  10. #   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. #   GNU General Public License for more details.
  13. #
  14. #   You should have received a copy of the GNU General Public License
  15. #   along with this program; if not, write to the Free Software
  16. #   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  
  18. #   plugin.py -- helper for writing gimp plugins
  19. #     Copyright (C) 1997, James Henstridge.
  20. #
  21. # This is a small wrapper that makes plugins look like an object class that
  22. # you can derive to create your plugin.  With this wrapper, you are pretty
  23. # much responsible for doing everything (checking run_mode, gui, etc).  If
  24. # you want to write a quick plugin, you probably want the gimpfu module.
  25. #
  26. # A plugin using this module would look something like this:
  27. #
  28. #   import gimp, gimpplugin
  29. #
  30. #   pdb = gimp.pdb
  31. #
  32. #   class myplugin(gimpplugin.plugin):
  33. #       def query(self):
  34. #           gimp.install_procedure("plug_in_mine", ...)
  35. #
  36. #       def plug_in_mine(self, par1, par2, par3,...):
  37. #           do_something()
  38. #
  39. #   if __name__ == '__main__':
  40. #       myplugin().start()
  41.  
  42. import gimp
  43.  
  44. class plugin:
  45.     def start(self):
  46.         gimp.main(self.init, self.quit, self.query, self._run)
  47.  
  48.     def init(self):
  49.         pass
  50.  
  51.     def quit(self):
  52.         pass
  53.  
  54.     def query(self):
  55.         pass
  56.  
  57.     def _run(self, name, params):
  58.         if hasattr(self, name):
  59.             return apply(getattr(self, name), params)
  60.         else:
  61.             raise AttributeError, name
  62.  
  63. if __name__ == '__main__':
  64.     plugin().start()
  65.